package net.sk.china.platform.task.user;

import net.sk.china.platform.service.user.UserIntegralRecordService;
import net.sk.china.platform.task.order.StoreOrderTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 积分冻结期解冻定时任务
 * +----------------------------------------------------------------------
 * | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2018-2024 聊来All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * +----------------------------------------------------------------------
 * | @Author: 聊来 <18970881148@qq.com>
 * +----------------------------------------------------------------------
 * | DateTime: 2024/6/14 22:37
 * +----------------------------------------------------------------------
 */

@Component
@EnableScheduling
public class IntegralFrozenTask {

    private static final Logger logger = LoggerFactory.getLogger(IntegralFrozenTask.class);

    public final UserIntegralRecordService userIntegralRecordService;

    public IntegralFrozenTask(UserIntegralRecordService userIntegralRecordService) {
        this.userIntegralRecordService = userIntegralRecordService;
    }

    @Async("taskExecutor")
    @Scheduled(fixedDelay = 1000 * 60L) //1分钟同步一次数据
    public void init() {
        try {
            userIntegralRecordService.integralThaw();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("积分冻结期解冻定时任务失败: " + e.getMessage());
        }

    }
}
